<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>

    const start = {
        name:"admin",
        age:18,
        sex:"男"
    }

    function kidnap(o){
        const target = {};

        for(let i in o){
            Object.defineProperty(target, i, {
                get(){
                    console.log(`获取了${i}属性`);
                    return o[i];
                },
                set(v){
                    console.log(`修改了${i}属性的值为${v}`);
                    o[i] = v;
                }
            })
        }

        return target;
    }

    const obj = kidnap(start);

    obj.name
    obj.age
    obj.sex

    obj.name = "root"
    obj.age = 19
    obj.sex = "女"

    console.log(start);
    console.log(obj);
    
</script>
</html>